import {globalIgnores} from 'eslint/config';
import {defineConfigWithVueTs, vueTsConfigs} from '@vue/eslint-config-typescript';
import pluginVue from 'eslint-plugin-vue';
import pluginVitest from '@vitest/eslint-plugin';
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import pluginCypress from 'eslint-plugin-cypress';
import pluginOxlint from 'eslint-plugin-oxlint';
import skipFormatting from '@vue/eslint-config-prettier/skip-formatting';

// To allow more languages other than `ts` in `.vue` files, uncomment the following lines:
// import { configureVueProject } from '@vue/eslint-config-typescript'
// configureVueProject({ scriptLangs: ['ts', 'tsx'] })
// More info at https://github.com/vuejs/eslint-config-typescript/#advanced-setup

export default defineConfigWithVueTs(
  // {
  //   name: 'app/files-to-lint',
  //   files: ['**/*.{ts,mts,tsx,vue}'],
  // },

  globalIgnores(['**/dist/**', '**/dist-ssr/**', '**/coverage/**']),

  // pluginVue.configs['flat/essential'],
  // vueTsConfigs.recommended,
  {
    // 自定义规则
    rules: {
      '@typescript-eslint/no-unused-vars': 'off',
      indent: [
        'error',
        2,
        {
          SwitchCase: 1,
        },
      ],
      // vue 组件命名规则
      'vue/multi-word-component-names': 'off', // 关闭组件命名规则
      // 'vue/multi-word-component-names': [
      //   'error',
      //   {
      //     ignores: ['index', 'Header'], //需要忽略的组件名
      //   },
      // ],
      '@typescript-eslint/no-var-requires': 'off',
      '@typescript-eslint/no-explicit-any': 'off',
      semi: 'off',
      '@typescript-eslint/no-this-alias': 'off',
      'eslintno-debugger': 'off',
      'vue/no-unused-vars': 'off',
      'vue/no-template-shadow': 'off',
      'vue/require-v-for-key': 'off',
      'vue/no-textarea-mustache': 'off',
      'vue/no-v-html': 'off',
    },
  },

  {
    ...pluginVitest.configs.recommended,
    files: ['src/**/__tests__/*'],
  },

  {
    ...pluginCypress.configs.recommended,
    files: ['cypress/e2e/**/*.{cy,spec}.{js,ts,jsx,tsx}', 'cypress/support/**/*.{js,ts,jsx,tsx}'],
  },
  ...pluginOxlint.configs['flat/recommended'],
  skipFormatting,
);
